package com.lins.framework.utils.toolbar;

import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.lins.framework.R;
import com.lins.framework.common.base.MyApplication;

/**
 * Created by Admin on 2017/3/17.
 */

public class AppToolBar {
    private Activity activity;
    private android.support.v7.widget.Toolbar idToolbar;
    private String title;
    private TextView idTvTitle;
    private ImageView idImgBack;

    public AppToolBar(Activity activity, android.support.v7.widget.Toolbar idToolbar, String title) {
        this.activity = activity;
        this.idToolbar = idToolbar;
        this.title = title;
        initToobar();
    }

    private void initToobar() {
        idTvTitle = (TextView) idToolbar.findViewById(R.id.id_tv_title);
        idImgBack = (ImageView) idToolbar.findViewById(R.id.id_img_back);
        idTvTitle.setText(title);
        idImgBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                goBack();
            }
        });
    }

    public void setTitle(String msg) {
        idTvTitle.setText(msg);
    }

    private void goBack() {
//        SoftInputUtil.hideSoftInputFromWindowOnBack(context, activity);
        MyApplication.getInstance().getActivityManager().finishThis();
    }

}
